#ifndef __MOTORS_H__
#define __MOTORS_H__

#include <avr/io.h>
#include "../common.h"

#define TCCR0A_INIT     (_BV(COM0B1) | _BV(WGM01) | _BV(WGM00)) 
#define TCCR0B_INIT     (_BV(CS02))     

#define TCCR2A_INIT     (_BV(COM2A1) | _BV(COM2B1) | _BV(WGM21) | _BV(WGM20)) 
#define TCCR2B_INIT     (_BV(CS22))

#define TOC_LEFT                OCR2A           // Left Motor PWM PB4 = OC2A
#define LEFT_DIR                3               // Left motor direction PC3
#define TOC_CENTER              OCR0B           // Center Motor PWM PD0 = OC0B
#define CENTER_DIR              5               // Left motor direction PC5
 
/* PB7 = OC0A not used for motors */
#define TOC_RIGHT               OCR2B           // Right Motor PWM PD1 = OC2B
#define RIGHT_DIR               4               // Right motor direction PC4
 
/* PB7 */
#define DDROCA                  DDRB
#define DDROCA_MASK     _BV(4)
/* PD0 and PD1 */
#define DDROCB                  DDRD            
 
#define DDROCB_MASK             _BV(0) | _BV(1)
 
#define DDR_DIR                 DDRC            
#define DDR_DIR_MASK    (_BV(4) | _BV(5) | _BV(3) )
 
enum motor_number {LEFT_MOTOR, CENTER_MOTOR, RIGHT_MOTOR};
 
void pwm_motors_init(void);
void pwm_set_duty (enum motor_number n, int duty);
 
#endif         

